import java.util.LinkedList;
import java.util.Stack;

public class Test {
    public static void main(String[] args) {
        LinkedList<Integer> stack = new LinkedList<>();
        stack.push(111);
        stack.push(222);
        stack.push(333);




    }
    public static void main2(String[] args) {
        MyStack myStack = new MyStack();
        myStack.push(111);
        myStack.push(222);
        myStack.push(333);
        System.out.println(myStack.peek());
        myStack.pop();
        System.out.println(myStack.peek());
        System.out.println(myStack.pop());
        System.out.println(myStack.pop());
        System.out.println(myStack.pop());
        System.out.println(myStack.pop());
    }
    public static void main1(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(11);
        stack.push(12);
        stack.push(13);
        System.out.println(stack.pop());
        System.out.println(stack.peek());
        System.out.println(stack.pop());
        System.out.println(stack.pop());


    }
    public boolean isValid(String s){
        Stack<Character> satck = new Stack<>();//new一个栈出来
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);//每次获取一个字符
            if(ch == '(' || ch =='{' || ch == '['){//满足条件放到栈里面
                satck.push(ch);
            }else{ //不是左括号，就是遇到右括号
                if(satck.isEmpty()){//如果栈是空的
                    return false;
                }
                //此是开始判断是否匹配
                char ch2 = satck.peek();//获取栈顶元素
                if(ch == ')' && ch2 == '(' || ch == '}' && ch2 == '{'||ch == ']' && ch2 == '[' ){//括号匹配就出栈
                    satck.pop();
                }else {
                    return false;
                }
            }
        }
        if(!satck.isEmpty()){
            return false;
        }
        return true;

    }
}
